package com.nan.buy.service.Impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.nan.buy.common.UUIDUtil;
import com.nan.buy.dao.IdeaMapper;
import com.nan.buy.model.Idea;
import com.nan.buy.service.IdeaService;

@Service
public class IdeaServiceIpml implements IdeaService{

	@Resource
	private IdeaMapper ideaMapper;
	
	@Override
	public List<Idea> searchIdea() {
		return ideaMapper.searchIdea();
	}

	@Override
	public int updateIdea(Idea idea) {
		Date date=new Date();
		String dateStr = new SimpleDateFormat("MM-dd-yyyy").format(date);
		idea.setReTime(dateStr);
		return ideaMapper.updateByPrimaryKeySelective(idea);
	}

	@Override
	public int updateIdeaReMsg(Idea idea) {
		idea.setReMessage("暂无回复消息");
		idea.setReTime(new SimpleDateFormat("MM-dd-yyyy").format(new Date()));
		return ideaMapper.updateByPrimaryKeySelective(idea);
	}

	@Override
	public int insertSelective(Idea idea) {
		idea.setId(UUIDUtil.getUUID());
		idea.setNewTime(new SimpleDateFormat("MM-dd-yyyy").format(new Date()));
		return ideaMapper.insertSelective(idea);
	}

}
